<template>
  <div>
    <div class="weui-flex  bdl xl primary pdh">
      <div class="weui-flex__item">选择布置作业的班级</div>
      <div class=""><a @tap="handleCreateGroup">+ 新建班级</a></div>
    </div>
    <div class="groups pd-l" style="padding-left: 0;">
      <a v-for="n in _groups" :key="n.id"
        :class="{'checked': n.checked}"
        @tap="handleToggleCheckGroup(n.id)">{{n.name}}</a>
    </div>
  </div>
</template>

<script>
import { mapGetters, mapActions, mapState } from 'vuex'
export default {
  computed: {
    ...mapGetters('task-create-select-group', [
      '_groups'
    ])
  },
  methods: {
    ...mapActions('task-create-select-group', [
      'handleToggleCheckGroup',
      'handleCreateGroup',
    ])
  }
}
</script>

<style scoped lang="less">
@import "../../assets/less/var.less";

.groups {
  a {
    display: inline-block;
    border: 1px solid @colorBlack;
    padding: 0 10px;
    border-radius: 3px;
    color: @colorBlack;
    margin-left: 20px;
    margin-bottom: 10px;
    &.checked {
      border-color: @colorPrimary;
      color: @colorPrimary;
    }
  }
}
</style>
